home *** CD-ROM | disk | FTP | other *** search
- // PaperOrientation.cpp : implementation file
- //
-
- #include "stdafx.h"
- #include "resource.h"
- #include "PaperOrientation.h"
- #include "PaperSpaceWizard.h"
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- /////////////////////////////////////////////////////////////////////////////
- // CPaperOrientation property page
-
- IMPLEMENT_DYNCREATE(CPaperOrientation, CPropertyPage)
-
- CPaperOrientation::CPaperOrientation() : CPropertyPage(CPaperOrientation::IDD)
- {
- //{{AFX_DATA_INIT(CPaperOrientation)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
- }
-
- CPaperOrientation::~CPaperOrientation()
- {
- }
-
- void CPaperOrientation::DoDataExchange(CDataExchange* pDX)
- {
- CPropertyPage::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CPaperOrientation)
- // NOTE: the ClassWizard will add DDX and DDV calls here
- //}}AFX_DATA_MAP
- }
-
-
- BEGIN_MESSAGE_MAP(CPaperOrientation, CPropertyPage)
- //{{AFX_MSG_MAP(CPaperOrientation)
- ON_BN_CLICKED(IDC_PORIENTATIONP, OnPorientationp)
- ON_BN_CLICKED(IDC_PORIENTATIONL, OnPorientationl)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CPaperOrientation message handlers
-
- BOOL CPaperOrientation::OnSetActive()
- {
- // CPropertySheet* pSheet = (CPropertySheet*)GetParent();
- CPaperSpaceWizard* pSheet = (CPaperSpaceWizard*)GetParent();
-
- ASSERT_KINDOF(CPropertySheet, pSheet);
- pSheet->SetWizardButtons( PSWIZB_BACK | PSWIZB_FINISH);
- LPTSTR IDB;
- CButton *pRadioB = (CButton *) GetDlgItem(IDC_PORIENTATIONL);
- CButton *pRadioB1 = (CButton *) GetDlgItem(IDC_PORIENTATIONP);
- CStatic *pPaperPreview = (CStatic *) GetDlgItem(IDC_PAPERPREVIEW);
-
-
- if (pSheet->m_PSInfo->bPaperOrientation == 0)
- {
- IDB = MAKEINTRESOURCE(IDI_ICONP);
- pRadioB1->SetCheck(1);
- pRadioB->SetCheck(0);
- }
- else
- {
- IDB = MAKEINTRESOURCE(IDI_ICONL);
- pRadioB1->SetCheck(0);
- pRadioB->SetCheck(1);
-
- }
- HICON pIcon = ::LoadIcon (AfxGetResourceHandle(), IDB);
- pPaperPreview->SetIcon (pIcon);
- // int i = DeleteObject(pBmp);
-
- /*
- if (pSheet->m_PSInfo.bPaperOrientation == 0)
- CPaperOrientation::OnPorientationp ();
- else
- CPaperOrientation::OnPorientationl ();
- */
- return CPropertyPage::OnSetActive();
- }
-
- void CPaperOrientation::OnPorientationp()
- {
- // TODO: Add your control notification handler code here
- LPTSTR IDB;
-
- CButton *pRadioB = (CButton *) GetDlgItem(IDC_PORIENTATIONL);
- pRadioB->SetCheck(0);
- CButton *pRadioB1 = (CButton *) GetDlgItem(IDC_PORIENTATIONP);
- pRadioB1->SetCheck(1);
-
- CStatic *pPaperPreview = (CStatic *) GetDlgItem(IDC_PAPERPREVIEW);
- IDB = MAKEINTRESOURCE(IDI_ICONP);
- HICON pIcon = ::LoadIcon (AfxGetResourceHandle(), IDB);
- pPaperPreview->SetIcon (pIcon);
- int i = DeleteObject(pIcon);
- CPaperSpaceWizard* pSheet = (CPaperSpaceWizard*)GetParent();
- pSheet->m_PSInfo->bPaperOrientation = 0;
- }
-
- void CPaperOrientation::OnPorientationl()
- {
- // TODO: Add your control notification handler code here
- LPTSTR IDB;
- CButton *pRadioB = (CButton *) GetDlgItem(IDC_PORIENTATIONP);
- pRadioB->SetCheck(0);
-
- CButton *pRadioB1 = (CButton *) GetDlgItem(IDC_PORIENTATIONL);
- pRadioB1->SetCheck(1);
-
- CStatic *pPaperPreview = (CStatic *) GetDlgItem(IDC_PAPERPREVIEW);
-
- IDB = MAKEINTRESOURCE(IDI_ICONL);
- // HBITMAP pBmp = ::LoadBitmap(AfxGetResourceHandle(), IDB);
- HICON pIcon = ::LoadIcon (AfxGetResourceHandle(), IDB);
- pPaperPreview->SetIcon (pIcon);
- int i = DeleteObject(pIcon);
- CPaperSpaceWizard* pSheet = (CPaperSpaceWizard*)GetParent();
- pSheet->m_PSInfo->bPaperOrientation = 1;
-
- }
-
- BOOL CPaperOrientation::OnWizardFinish()
- {
- // TODO: Add your specialized code here and/or call the base class
-
- CPaperSpaceWizard* pSheet = (CPaperSpaceWizard*)GetParent();
- BSTR bstrPsName;
- HRESULT hRes = E_FAIL;
- PaperSpace *pPs = NULL;
- IDispatch *pDisp = NULL;
- try
- {
- bstrPsName = pSheet->m_PSInfo->cstrPSpaceName.AllocSysString ();
- hRes = pSheet->m_pPss->Add(bstrPsName, &pDisp);
- CHECK_HRESULT(hRes)
- hRes = pDisp->QueryInterface (IID_PaperSpace, (void**)&pPs);
- CHECK_HRESULT(hRes)
-
- hRes = pPs->Activate();
- CHECK_HRESULT(hRes)
-
- }
- catch(...)
- {
- TRACE("CPaperOrientation::OnWizardFinish()");
- }
-
- RELEASE(pPs);
- RELEASE(pDisp)
-
- RELEASE(pSheet->m_pPss);
-
- return CPropertyPage::OnWizardFinish();
- }
-